var question = new Array(
"1.gif",
"2.gif",
"3.gif",
"4.gif",
"5.gif",
"6.gif",
"7.gif",
"8.gif",
"9.jpg"
);

var resultquestion = new Array(
"7",
"0",
"2",
"5",
"4",
"6"
);

$(function() {
    var lii = '';
    $.each(question, function(key, val) {        
        lii += '<li id="'+key+'" class="imagesyl"><img src="images/'+val+'" /></li>';
    });
    $('#sortable1').append(lii);

    $( "ul.droptrue" ).sortable({
        connectWith: "ul.group",
        cursor: "move",
        placeholder: "ui-state-highlight"
    });

    $( "ul.group" ).sortable({
        connectWith: "ul.droptrue, ul.group",
        cursor: "move",
        placeholder: "ui-state-highlight"
    });

    $( ".group, .droptrue" ).disableSelection();

    $('#submit').click(function() {
        var result1;var result2;var result3;
        var result4;var result5;var result6;
        var count = 0;
        $('#group1').children().each(function(){
                var kid = $(this);
                var tmp = (kid.attr('id'));
                result1 = tmp;
        });
        $('#group2').children().each(function(){
                var kid = $(this);
                var tmp = (kid.attr('id'));
                result2 = tmp;
        });
        $('#group3').children().each(function(){
                var kid = $(this);
                var tmp = (kid.attr('id'));
                result3 = tmp;
        });
        $('#group4').children().each(function(){
                var kid = $(this);
                var tmp = (kid.attr('id'));
                result4 = tmp;
        });
        $('#group5').children().each(function(){
                var kid = $(this);
                var tmp = (kid.attr('id'));
                result5 = tmp;
        });
        $('#group6').children().each(function(){
                var kid = $(this);
                var tmp = (kid.attr('id'));
                result6 = tmp;
        });
        $('#sortable1').children().each(function(){
                count ++;

        });
        //alert(result_1+'-'+result_2+'-'+result_3+'-'+result_4+'-'+result_5);
        if (result1 == resultquestion[0]
            && result2 == resultquestion[1]
            && result3 == resultquestion[2]
            && result4 == resultquestion[3]
            && result5 == resultquestion[4]
            && result6 == resultquestion[5]
            && count == 3) {
                $('.dialogNoteS').dialog({
                    modal: true,
                    buttons: {
                            Ok: function() {
                                location.replace('../finddiff/index.html');
                            }
			}
                });
            } else {
                $('.dialogNoteE').dialog({
                    modal: true,
                    buttons: {
                            Ok: function() {                                
                                $( this ).dialog( "close" );
                            }
			}
                });
            }
    });
});